﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace PRE.Catalog
{
    public partial class frmChucvu_load : Form
    {
        DAL.Entities_DAL.Chucvu_DAL _dal = new DAL.Entities_DAL.Chucvu_DAL();
        BLL.Entities_BLL.Xu_ly_chung _chung = new BLL.Entities_BLL.Xu_ly_chung();

        public frmChucvu_load()
        {
            InitializeComponent();
        }

        private void frmChucvu_load_Load(object sender, EventArgs e)
        {

        }

        private void cmdLammoi_Click(object sender, EventArgs e)
        {
            txtMacv.Text = null;
            txtTencv.Text = null;
        }

        private void cmdThoat_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void cmdLuu_Click(object sender, EventArgs e)
        {
            
            var name = _chung.Proper(txtTencv.Text);

            
                var o = new DAL.Entities.CHUC_VU
                {
                    MA_CV = txtMacv.Text,

                    TEN_CV = name,

                };

                var oki = _dal.Insert(o);
                if (oki)
                {
                    MessageBox.Show("Đã lưu thành công", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Lỗi! Lưu thất bại", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    
                }

        }
    }
}
